package com.group.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.group.dao.TbContractMapper;
import com.group.pojo.TbContract;
import com.group.pojo.TbContractExample;
import com.group.pojo.TbContractExample.Criteria;
import com.group.service.CommonService;
import com.group.service.ContractService;

@Service
public class ContractServiceImpl implements ContractService {
	@Autowired
	private TbContractMapper contractMapper;
	
	@Autowired
	private CommonService commonService;

	private void setCondition(Criteria criteria, TbContract contract) {
		String id = contract.getId();
		if(id != null && !"".equals(id)) {
			criteria.andIdEqualTo(id);
		}
		
		String customerId = contract.getCustomerId();
		if (customerId != null && !"".equals(customerId)) {
			criteria.andCustomerIdEqualTo(customerId);
		}
		
		String contractStatus = contract.getContractStatus();
		if (contractStatus != null && !"".equals(contractStatus)) {
			criteria.andContractStatusEqualTo(contractStatus);
		}
		
	}
	@Override
	public List<TbContract> query(TbContract contract) {
		TbContractExample example = new TbContractExample();
		
		setCondition(example.createCriteria(), contract);
		
		List<TbContract> list = contractMapper.selectByExample(example);
		return list;
	}


	 
}
